﻿using BLL;
using Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace 图书管理系统
{
    /// <summary>
    /// RegWin.xaml 的交互逻辑
    /// </summary>
    public partial class RegWin : Window
    {
        public RegWin()
        {
            InitializeComponent();
            this.WindowStartupLocation = WindowStartupLocation.CenterScreen;
        }
        private static UserInfoTabBll bll = new UserInfoTabBll();
        private void button_Copy1_Click(object sender, RoutedEventArgs e)
        {
            if (txtId.Text.Trim()==""||txtPwd.Password.Trim()==""||txtPwd2.Password.Trim()=="")
            {
                MessageBox.Show("请将信息填写完整!");
                return;
            }

            UserInfo model = new UserInfo();
            model.ID = txtId.Text.Trim();
            model.Password = txtPwd.Password.Trim();

            bool b=bll.Reg(model);
            if (b)
            {
                MessageBox.Show("注册成功!","温馨提示",MessageBoxButton.OK,MessageBoxImage.Asterisk);
                this.Close();
            }
            else
            {
                MessageBox.Show("该账号已注册，请重写输入账号","温馨提示");
                
            }
        }

        private void button_Copy_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }
    }
}
